package com.example.owner.lettery1.modlus



object SplitBall {

    fun splitBall( openNumber: String): ArrayList<Ball>{
        val ballList = ArrayList<Ball>()
        if (openNumber.contains(":")) {
            val balls = openNumber!!.split(":")
            val redString = balls[0]
            val blueString = balls[1]
            val redBalls = redString.split(",")
            val blueBalls = blueString.split(",")
            for (num in redBalls) {
                val ball = Ball()
                ball.number = num
                ball.isSelector = false
                ballList.add(ball)
            }
            for (num in blueBalls) {
                val ball = Ball()
                ball.number = num
                ball.isSelector = true
                ballList.add(ball)
            }
        } else {
            val balls = openNumber!!.split(",")
            for (num in balls) {
                val ball = Ball()
                ball.number = num
                ball.isSelector = false
                ballList.add(ball)
            }
        }
        return ballList
    }
}